<?php
/**
 * RegistrationForm class.
 * RegistrationForm is the data structure for keeping
 * user registration form data. It is used by the 'registration' action of 'UserController'.
 */
class RegistrationForm extends User {
	public $verifyPassword;
	public $verifyCode;
	
	public function rules() {
		$rules = array(
			array('username, password,  verifyPassword, verifyCode, email', 'required'),
			array('username', 'length', 'max'=>20, 'min' => 3,'message' => Yii::t("message","Incorrect username (length between 3 and 20 characters).")),
			array('password', 'length', 'max'=>128, 'min' => 6,'message' => Yii::t("message","Incorrect password (minimal length 6 symbols).")),
			array('email', 'email'),
			array('username', 'unique', 'message' => Yii::t("message","This user's name already exists.")),
			array('email', 'unique', 'message' => Yii::t("message","This user's email address already exists.")),
			array('verifyPassword', 'compare', 'compareAttribute'=>'password', 'message' => Yii::t("message","Re-type Password is incorrect.")),
			array('username', 'match', 'pattern' => '/^[A-Za-z0-9_]+$/u','message' => Yii::t("message","Incorrect symbols (A-z 0-9).")),
            array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements())
		);
		return $rules;
	}
    
    public function attributeLabels()
    {
        return array_merge(
            parent::attributeLabels(),
            array(
                'verifyPassword'=>Yii::t('label','Nhập lại mật khẩu'),
                'verifyCode'=>Yii::t('label','Mã xác thực'),
        ));
    }
}